import java.util.Comparator;

public class TeacherComparator implements Comparator<Teacher> {
    @Override
    public int compare(Teacher t1, Teacher t2) {
        // 先按名字排序
        int nameCompare = t1.getName().compareTo(t2.getName());
        if (nameCompare != 0) {
            return nameCompare;
        }

        // 名字相同则按年龄排序
        int ageCompare = Integer.compare(t1.getAge(), t2.getAge());
        if (ageCompare != 0) {
            return ageCompare;
        }

        // 年龄相同则按id排序
        return Integer.compare(t1.getId(), t2.getId());
    }
}
